import Flutter
import UIKit

public class SwiftFlutterPluginNimrtcPlugin: NSObject, FlutterPlugin, UINavigationControllerDelegate {
    private var hostViewController: UIViewController?
    
    public static func register(with registrar: FlutterPluginRegistrar) {
        let channel = FlutterMethodChannel(name: "flutter_plugin_nimrtc", binaryMessenger: registrar.messenger())
        let instance = SwiftFlutterPluginNimrtcPlugin()
        instance.hostViewController = UIApplication.shared.delegate?.window??.rootViewController
        registrar.addMethodCallDelegate(instance, channel: channel)
    }
    
    public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
        switch call.method {
        case "getPlatformVersion":
            result(UIDevice.current.systemVersion)
            break
        case "call":
            let arguments: Dictionary<String, Any> = call.arguments as! Dictionary
            let appId: String = arguments["appId"] as! String
            let roomId: String = arguments["roomId"] as! String
            nimCall(result:result,appId:appId,roomId:roomId)
            break
        default:result(FlutterError(code: "no method", message: "no method", details: nil))
        }
    }
    func nimCall(result: @escaping FlutterResult,appId: String,roomId: String) {
        print("call");
        result(nil)
    }
}
